<?php
/**
 * +----------------------------------------------------------------------
 * | [ DO WHAT YOU LOVE AND FUCK THE REST ]
 * +----------------------------------------------------------------------
 * | EMAIL: < 931274989@qq.com >
 * +----------------------------------------------------------------------
 * | WECHAT: xzc016
 * +----------------------------------------------------------------------
 * | 登录
 * +----------------------------------------------------------------------
 */
namespace app\admin\controller;

use app\admin\model\Admin;
use app\common\model\System;

use think\facade\Request;
use think\facade\Session;
use think\facade\View;
use think\captcha\facade\Captcha;

class Login
{
  // 登录页面
  public function index()
  {
    //查找格式化所有系统设置表数据
    $view['mobile'] = Request::isMobile();  // 是否是手机访问
    $view['system'] = System::where('web','web')->find()->toArray();
    View::assign($view);
    return View::fetch();
  }
 
  // 校验登录
  public function checkLogin(){
    return Admin::checkLogin();
  }
 
  // 验证码
  public function captcha(){
    return Captcha::create();
  }
 
  // 退出登录
  public function logout(){
    Session::delete('admin');
    if(Session::has('admin')) {
      $error = ['code' => 0, 'msg' => '退出失败' ];
      return $error;
    } else {
      $success = [  'code' => 1, 'msg' => '退出成功' ];
      return $success;
    }
  }

}

?>